const ipcMainUrl = import.meta.env.VITE_IPCMAIN_URL

export default {
  // 显示浏览器视图
  async showBrowserView() {
    return await window.electron.ipcRenderer.invoke(ipcMainUrl, {
      name: 'show-browser-view'
    })
  },

  // 隐藏浏览器视图
  async hideBrowserView() {
    return await window.electron.ipcRenderer.invoke(ipcMainUrl, {
      name: 'hide-browser-view'
    })
  },

  async getSettings() {
    return await window.electron.ipcRenderer.invoke(ipcMainUrl, {
      name: 'get-application-settings'
    })
  },

  async validateSingleShortcut(key: string, accelerator: string) {
    return await window.electron.ipcRenderer.invoke(ipcMainUrl, {
      name: 'validate-single-shortcut',
      data: { key, accelerator }
    })
  },

  async saveSingleShortcut(
    key: 'shortcut1' | 'shortcut2' | 'shortcut3' | 'shortcut4',
    accelerator: string
  ) {
    return await window.electron.ipcRenderer.invoke(ipcMainUrl, {
      name: 'save-application-shortcut',
      data: { key, accelerator }
    })
  },

  async pickRecordingPath(): Promise<string | null> {
    return await window.electron.ipcRenderer.invoke(ipcMainUrl, {
      name: 'pick-recording-path'
    })
  },

  async saveRecordingPath(path: string) {
    return await window.electron.ipcRenderer.invoke(ipcMainUrl, {
      name: 'save-recording-path',
      data: { path }
    })
  },

  async applyShortcuts() {
    return await window.electron.ipcRenderer.invoke(ipcMainUrl, {
      name: 'apply-shortcuts'
    })
  }
}
